package router

import (
	"cron-go/internal/app/cron"
	"net/http"
	"os"

	"github.com/gin-gonic/gin"
)

func RegisterRouter(ginRouter *gin.Engine) {
	ginRouter.GET("/", Index)
	g := ginRouter.Group("/api/v1")
	g.GET("/health", GetHealthInfo)

	cron.RegisterTaskAPI(ginRouter)
	//test
	ginRouter.GET("/get", GetDemo)
	ginRouter.POST("/post", PostDemo)
}

// 入口
func Index(c *gin.Context) {
	c.String(http.StatusOK, "Hello,It works. ")
}

func GetHealthInfo(c *gin.Context) {
	host, _ := os.Hostname()
	message := "ok"
	c.JSON(http.StatusOK, gin.H{
		"code":    0,
		"message": message,
		"host":    host,
	})
}
